<template>
  <div style="width: 100%; height: 400px" />
</template>

<script>
import * as echarts from 'echarts'
import resize from '@/mixins/resize'
import { getDeviceTrend } from '@/api/dashboard'

export default {
  mixins: [resize],
  data() {
    return {
      chart: null
    }
  },
  computed: {},
  methods: {
    initChart(data) {
      this.chart = echarts.init(this.$el)

      const option = {
        legend: {
          // data: [this.$t('data_center.new_user_count')]
          data: ['Activated Devices'],
          bottom: '20px'
        },
        tooltip: {
          show: true,
          trigger: 'axis'
        },
        xAxis: {
          type: 'category',
          show: true,
          data: data.xaxisData.map(function(item) {
            return item
          })
        },
        yAxis: {
          type: 'value',
          show: true,
          minInterval: 1
        },
        grid: {
          x: 60,
          y: 60,
          x2: 60,
          y2: 80
        },
        series: [
          {
            name: 'Activated Devices',
            type: 'line',
            clip: true,
            symbol: 'none',
            lineStyle: {
              color: '#3086FA',
              width: 2
            },
            smooth: 0.4,
            showSymbol: false,
            areaStyle: {
              opacity: 0.5,
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                {
                  offset: 0,
                  color: '#3086FA'
                },
                {
                  offset: 1,
                  color: '#ffffff'
                }
              ])
            },
            data: data.yaxisData
          }
        ]
      }
      this.chart.setOption(option)
    }
  }
}
</script>

<style>
</style>
